﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JTicket.UI
{
    public partial class JT_SaleZC : System.Web.UI.Page
    {
        private readonly BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.TextBox1.Text = DAL.D_TaoTab.GetIndex();
            if (!IsPostBack)
                bind();
        }
        void bind()
        {

            if (!string.IsNullOrEmpty(Request.QueryString["TitleCode"].ToString()))
            {
                this.Label1.Text = Request.QueryString["Title"].ToString();


                Model.D_OperInfo oper = bllOper.Oper();
                List<Model.D_TaoTab> list = DAL.D_TaoTab.GetList(Request.QueryString["Titlecode"].ToString(), Request.QueryString["Thcode"].ToString());

                this.dg1.DataSource = list;
                this.dg1.DataBind();
            }
        }
        protected void BtnAdd_Click(object sender, EventArgs e)
        {

            if (this.TextBox1.Text != "" && this.TextBox2.Text != ""
                && this.TextBox3.Text != "" && this.TextBox4.Text != "")
            {
                if (!string.IsNullOrEmpty(Request.QueryString["TitleCode"].ToString()))
                {
                    Model.D_TaoTab tao = new Model.D_TaoTab();
                    tao.concertcode = Request.QueryString["TitleCode"].ToString();
                    tao.status = 1;
                    tao.TaoCode = this.TextBox1.Text;
                    tao.TaoName = this.TextBox2.Text;
                    tao.TaoPortfolio = this.TextBox4.Text;
                    tao.TaoPrice = Convert.ToDecimal(this.TextBox3.Text);
                    tao.ThCode = Request.QueryString["ThCode"].ToString();
                    DAL.D_TaoTab.Add(tao);

                    this.TextBox1.Text = DAL.D_TaoTab.GetIndex();
                    this.TextBox2.Text = "";
                    this.TextBox3.Text = "";
                    this.TextBox4.Text = "";
                    bind();
                }
                else
                {
                    Common.JsMsg.Alert("参数错误！");
                }
            }
            else {
                Common.JsMsg.Alert("内容为空！");
            }
        }

        protected void BtnAdd0_Click(object sender, EventArgs e)
        {
            Response.Redirect("JT_TitleManager.aspx");
        }
    }
}